package org.terrier.matching.models.basicmodel;

import org.terrier.utility.ApplicationSetup;

public class WBcdf extends BasicModel {
	/*
     * Weibull cdf 
     */
    double wa = Double.parseDouble(ApplicationSetup.getProperty("distribution.parameter.0", "1.1"));
    double wb = Double.parseDouble(ApplicationSetup.getProperty("distribution.parameter.1", "0.5"));
    

	@Override
	public String getInfo() {
		return "WBcdf"+wa+"_"+wb+"_";
	}

	@Override
	public double score(double tf, double documentFrequency,
			double termFrequency, double keyFrequency, double documentLength) {
		/*
		 * weibull cdf
		 */
		return (1 - Math.exp(-Math.pow((tf / wa), wb)))*keyFrequency;
	}
	
	public void initModel(){
		String value = null;
		if ((value = ApplicationSetup.getProperty("distribution.parameter.0", "1.1d"))!=null){
			this.wa = Double.parseDouble(value);
		}
		if ((value = ApplicationSetup.getProperty("distribution.parameter.1", "0.5d"))!=null){
			this.wb = Double.parseDouble(value);
		}
	}

}
